home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0151.ZIP / LATTICE.ASH < prev    next >
Text File  |  1985-05-21  |  2KB  |  96 lines

  1. ;
  2. ;Assembly insert file to setup segments
  3. ;and access args on the stack for the various
  4. ;8086 models.
  5. ;
  6. ;Macros and equates defined here:
  7. ;
  8. ;CSEG        Create a code segment and type.
  9. ;ENDC        Close a code segment
  10. ;
  11. ;DSEG        Create a data segment
  12. ;ENDD        Close a data segment
  13. ;
  14. ;FUNC         Use to declare a function. Defines
  15. ;        it as far or near, appropriately. Also
  16. ;    pushes BP, sets BP to SP, and saves DS and ES.
  17. ;    (Requirements changed in v2)
  18. ;
  19. ;ENDF        Declare the end of a function. Restore
  20. ;        registers saved by FUNC.
  21. ;
  22. ;ARG0..9    Defined args from the stack, since
  23. ;        the offset depends on the size of
  24. ;    the return address: mov ax,ARG0 always gets
  25. ;    the right one.
  26. ;
  27. ;LONG        Defined as true if long pointers
  28. ;        are used. Use to conditionally 
  29. ;    assemble ES:[BX] or [BX] for pointer args.
  30. ;
  31. ; --- SMALL MODEL ---
  32. ;
  33. %out Small Code
  34. %out Small Data
  35.  
  36. extrn    dataseg:word
  37.  
  38.  _rgf    equ    2
  39.  
  40.  cseg macro
  41.   pgroup group prog
  42.   prog segment byte public 'prog'
  43.   assume cs:pgroup
  44.  endm
  45.  
  46.  endc macro
  47.   prog ends
  48.  endm
  49.  
  50.  dseg macro
  51.   dgroup group data
  52.   data segment byte public 'data'
  53.   assume ds:dgroup
  54.  endm
  55.  
  56.  endd macro
  57.   data ends
  58.  endm
  59.  
  60. ;
  61. ;Define a function as near or far.
  62. ;
  63.  func macro procname
  64.   public procname
  65.   procname proc near
  66.     push    bp
  67.     mov    bp,sp
  68.     push    ds
  69.     push    es
  70.     mov    ax,ds
  71.     mov    es,ax
  72.  endm
  73. ;
  74. ;Close a function declaration.
  75. ;
  76.  endf macro procname
  77.     pop    es
  78.     pop    ds
  79.     pop    bp
  80.     ret
  81.   procname endp
  82.  endm
  83. ;
  84. ;Define the args on the stack.
  85. ;
  86. arg0    equ    [bp+_rgf+2]
  87. arg1    equ    [bp+_rgf+4]
  88. arg2    equ    [bp+_rgf+6]
  89. arg3    equ    [bp+_rgf+8]
  90. arg4    equ    [bp+_rgf+10]
  91. arg5    equ    [bp+_rgf+12]
  92. arg6    equ    [bp+_rgf+14]
  93. arg7    equ    [bp+_rgf+16]
  94. arg8    equ    [bp+_rgf+18]
  95. arg8    equ    [bp+_rgf+20]
  96.